package com.tr.rentcar.controller.houtai.usermanage;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Response;

import com.tr.rentcar.model.dao.UserRecordDao;
import com.alibaba.fastjson.JSONArray;
import com.tr.rentcar.model.bean.UserRecord;

@WebServlet("/consumerecord")
public class consumerecordController extends HttpServlet {

	private static final long serialVersionUID = 1L;
	UserRecordDao UserRecordDao = new UserRecordDao();
	UserRecord UserRecord = new UserRecord();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
			req.setCharacterEncoding("utf-8");
			resp.setContentType("application/json;charset=utf-8");
			List<UserRecord> UserRecord = UserRecordDao.findAll();
			//req.setAttribute("record", UserRecord);

			PrintWriter out = resp.getWriter();
			out.print(JSONArray.toJSONString(UserRecord));

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// req.getRequestDispatcher("/WEB-INF/jsp/houtai_userManage.jsp").forward(req,
		// resp);
		// resp.sendRedirect(req.getContextPath()+"/houtai_user");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		doGet(req, resp);
	}

}
